<template>
	<view class="content">
		<view class="bg-img flex align-center " style="background-image:url('/static/images/6.jpg');height: 414upx;">
			<view class="padding-xl text-white">
				<view class="padding">
					<view class="cu-avatar round lg margin-left"
						style="background-image:url('/static/images/kefu.png')">
						<view class="cu-tag badge cuIcon-male bg-blue'">
						</view>
					</view>
					<view class="lg margin-sm" style="position: absolute;left:110px;top: 80px;font-size: 20px;">
						{{userInfo.realName}}
					</view>
				</view>

			</view>
		</view>
		<view class="cu-list menu" :class="[ 'sm-border', 'card-menu margin-top']">
			<view class="cu-item" :class=" 'arrow' ">
				<view class="content">
					<button class="cu-btn content" @click="openBook()">
						<image src="/static/images/wujiao.png" class="png" mode="aspectFit"></image>
						<text class="text-grey">我的账单</text>
					</button>
				</view>
			</view>
			<!-- <view class="cu-item" :class=" 'arrow' ">
				<view class="content">
					<image src="/static/images/cardbao.png" class="png" mode="aspectFit"></image>
					<text class="text-grey">我的卡包</text>
				</view>
			</view>
			<view class="cu-item" :class=" 'arrow' ">
				<view class="content">
					<image src="/static/images/qianbao.png" class="png" mode="aspectFit"></image>
					<text class="text-grey">我的积分</text>
				</view>
			</view>
			<view class="cu-item" :class=" 'arrow' ">
				<button class="cu-btn content" open-type="share">
					<image src="/static/images/feiji.png" class="png" mode="aspectFit"></image>
					<text class="text-grey">邀请好友</text>
				</button>
			</view> -->
			<view class="cu-item" :class=" 'arrow' ">
				<button class="cu-btn content" open-type="contact">
					<image src="/static/images/user.png" class="png" mode="aspectFit"></image>
					<text class="text-grey">联系后台管理员</text>
				</button>
			</view>
		</view>


		<view class="cu-list menu" :class="[ 'sm-border', 'card-menu margin-top']">

			<view class="cu-item">
				<button class="cu-btn content" @click="userLogout()">
					<image src="/static/images/feiji.png" class="png" mode="aspectFit"></image>
					<text class="text-grey">注销</text>
				</button>
			</view>
			<!-- 	<view class="cu-item" :class="'arrow' ">
				<view class="content">
					<image src="/static/images/help.png" class="png" mode="aspectFit"></image>
					<text class="text-grey">帮助中心</text>
				</view>
			</view> -->
		</view>

	</view>
</template>

<script>
	import {
		currentUserInfo,
		logout
	} from "@/api/index/index.js"
	export default {
		data() {
			return {
				title: 'MyHome',
				userInfo: {
					realName: '',
					avatar: '/static/images/kefu.png'
				}
			}
		},
		onLoad() {

		},
		created() {
			this.getUserInfo();
		},
		methods: {
			getUserInfo: function() {
				const loginUser = currentUserInfo();
				if (!loginUser) {
					uni.redirectTo({
						url: '/pages/login/login'
					});
				} else {
					this.userInfo.realName = loginUser['real_name'];
					console.log(this.userInfo.realName);
				}
			},
			openBook:function(){
				logout((res) => {
					uni.redirectTo({
						url: '/pages/index/index'
					})
				})
			},
			userLogout: function() {
				this.alertShow('注销登录');
				logout((res) => {
					uni.redirectTo({
						url: '/pages/login/login'
					})
				})
			},
			alertShow: function(msg) {
				uni.showToast({
					title: msg || '测试',
					duration: 2000,
					icon: 'none'
				});
			}
		}
	}
</script>

<style scoped>
	.userbackground {
		border-bottom-left-radius: 25%;
		border-bottom-right-radius: 25%;
	}
</style>
